package com.progark.sound.view;

import java.util.ArrayList;

import sheep.graphics.Color;
import sheep.graphics.Font;
import sheep.gui.TextButton;

import android.graphics.Canvas;
import android.graphics.Typeface;
import android.view.MotionEvent;

import com.progark.sound.controller.HighscoreController;
import com.progark.sound.main.Constants;

public class HighscoreView {
	
	private HighscoreController hsController;
	private Canvas canvas;
	private TextButton menuBackButton;

	public HighscoreView(HighscoreController hsController){
		this.hsController = hsController;
	}
	
	public void draw(Canvas canv){
		this.canvas = canv;
		canvas.drawPaint(Color.BLACK);

		ArrayList<String> toBePrintedOnScreen = hsController.getHighscoreList();
		
		canvas.drawText("Highscores", Constants.WIDTH/3, Constants.HEIGHT /6, new Font(255, 255, 255, 30, Typeface.DEFAULT_BOLD, Typeface.BOLD));
		String line;
		//x200y250
		for (int i = 0; i<toBePrintedOnScreen.size(); i++){
			line = i+1 + ". " +  toBePrintedOnScreen.get(i).split("~")[0] + " " + toBePrintedOnScreen.get(i).split("~")[1] ;
			canvas.drawText(line, Constants.WIDTH/3, Constants.HEIGHT/4 + i*20, new Font(255, 255, 255, 25, Typeface.DEFAULT_BOLD, Typeface.BOLD));
		}
		menuBackButton = new TextButton(Constants.WIDTH/3, Constants.HEIGHT- Constants.HEIGHT/4, "Back", Constants.alternativePaint);
		menuBackButton.draw(canv);
	}
	
	public boolean onTouchDown(MotionEvent event) {
		if (menuBackButton.onTouchDown(event)) {
			hsController.newMenu();
		} return true;
		
	}

}
